﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XMK.Framework.Model;
using XMK.Tadong.Data;
using XMK.Tadong.Model;
using XMK.Utils;
using XMK.Tadong.Model.Cond;
using System.Data;

namespace XMK.Tadong.Biz
{
    /// <summary>
    /// 权限——用户信息
    /// </summary>
    public class Base_RM_UserInfoBiz
    {
        /// <summary>
        /// 组织机构部门列表
        /// </summary>
        /// <returns></returns>
        public ResponseInfo QueryOrganizeList()
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (List<Base_OrganizationInfo>)data.GetOrganizeList();
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[GetOrganizeList:]" + ex.ToString());
            }
            return response;
        }

        /// <summary>
        ///  职工组织机构列表提取
        /// </summary>
        /// <returns></returns>
        public ResponseInfo QueryStaffOrganizeList()
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (List<Base_OrganizationInfo>)data.GetStaffOrganizeList();
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[GetOrganizeList:]" + ex.ToString());
            }
            return response;
        }

        /// <summary>
        /// 根据ID取部门数据
        /// </summary>
        /// <param name="ORGANIZATION_ID"></param>
        /// <returns></returns>
        public ResponseInfo GetOrganizeInfoByID(string ORGANIZATION_ID)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (Base_OrganizationInfo)data.GetOrganizeInfoByID(ORGANIZATION_ID);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[GetOrganizeInfoByID:]" + ex.ToString());
            }
            return response;
        }

        /// <summary>
        /// 部门编辑
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ResponseInfo EditOrganizationByID(Base_OrganizationCond cond)
        {
            if (string.IsNullOrEmpty(cond.ORGANIZATION_ID))
            {
                cond.ORGANIZATION_ID = Guid.NewGuid().ToString();
            }
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = data.EditOrganizationByID(cond);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[EditOrganizationByID:]" + ex.ToString());
            }
            return response;
        }

        public ResponseInfo QueryAllUser()
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = data.QueryAllUser();
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[QueryAllUser:]" + ex.ToString());
            }
            return response;
        }

        /// <summary>
        /// 用户信息列表
        /// </summary>
        /// <param name="cond"></param>
        /// <param name="page"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        public ResponseInfo QueryUserInfoPageList(Base_UserCond cond, PageInfo page, OrderInfo order)
        {
            ResponseInfo response = null;
            try
            {

                response = new ResponseInfo();
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response.Data = (List<Base_UserInfo>)data.GetUserInfoPageList(cond, page, order);
                response.Page = page;
            }
            catch (Exception ex)
            {
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[QueryUserInfoList:]" + ex.ToString());
            }

            return response;
        }

       /// <summary>
        /// 根据用户名密码取用户信息
       /// </summary>
       /// <param name="cond"></param>
       /// <returns></returns>
        public ResponseInfo GetUserInfoByNamePassword(Base_LoginCond cond)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (Base_UserInfo)data.GetUserByNamePassword(cond);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[GetUserInfoByNamePassword:]" + ex.ToString());
            }
            return response;

        }

        /// <summary>
        /// 取用户信息
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public ResponseInfo GetUserByID(string ID)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (Base_UserInfo)data.GetUserByID(ID);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[GetUserByID:]" + ex.ToString());
            }
            
            return response;

        }
        /// <summary>
        /// 取用户信息-model
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public Base_UserInfo GetUserModelByID(string ID)
        {
            Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
            return data.GetUserByID(Convert.ToString(ID));

        }

        /// <summary>
        /// 取登陆用户信息
        /// </summary>
        /// <returns></returns>
        public ResponseInfo GetCurrentUser()
        {
            ResponseInfo response = null;
            try
            {
                string ID = LoginUserBiz.LoginUserID();
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (Base_UserInfo)data.GetUserByID(ID);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[GetUserByID:]" + ex.ToString());
            }
            return response;

        }
        /// <summary>
        /// 取用户列表
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ResponseInfo QueryUserInfoList(Base_UserInfo cond)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (List<Base_UserInfo>)data.QueryUserInfo(cond);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[QueryUserInfoList:]" + ex.ToString());
            }
            return response;

        }
        /// <summary>
        /// 得到用户列表以及用户是否属于本课题组信息
        /// </summary>
        /// <param name="teamId"></param>
        /// <returns></returns>
        public string QueryUserByTeam(string teamId)
        {
            string jsonResult = "";
            try
            {
                DataColumn dc = new DataColumn();
                dc.DataType = typeof(System.Boolean);
                dc.ColumnName = "checked";
                //dc.ColumnName = "checked";
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                DataSet ds = data.QueryUserByTeam(teamId);
                DataTable dtUserTeam = ds.Tables[1];
                DataTable dt = ds.Tables[0];
                dt.Columns.Add(dc);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = dt.Rows[i];
                    DataRow[] rows = dtUserTeam.Select("USER_ID='" + Convert.ToString(dr["USER_ID"]) + "'");
                    if (rows.Length > 0)
                    {
                        dt.Rows[i]["checked"] = true;
                    }
                    else
                    {
                        dt.Rows[i]["checked"] = false;
                    }
                }
                jsonResult = JsonHelper.ToJson(dt);
            }
            catch (Exception ex)
            {
                string str = ex.Message;
            }


            return jsonResult;
        }

        /// <summary>
        /// 得到课题组用户
        /// </summary>
        /// <param name="teamId"></param>
        /// <returns></returns>
        public string QueryTeamUserByTeam(string teamId)
        {
            string jsonResult = "";
            try
            {
                DataColumn dc = new DataColumn();
                dc.DataType = typeof(System.Boolean);
                dc.ColumnName = "checked";
                               
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
               
                DataTable dtUserTeam = data.QueryTeamUserByTeam(teamId);

                dtUserTeam.Columns.Add(dc);

                for (int i = 0; i < dtUserTeam.Rows.Count; i++)
                {
                   
                    if (Convert.ToString(dtUserTeam.Rows[i]["DATAADMIN"]) =="1")
                    {
                        dtUserTeam.Rows[i]["checked"] = true;
                        
                    }
                    else
                    {
                        dtUserTeam.Rows[i]["checked"] = false;
                        
                    }
                }
                jsonResult = JsonHelper.ToJson(dtUserTeam);
            }
            catch (Exception ex)
            {
                string str = ex.Message;
            }


            return jsonResult;
        }
       /// <summary>
        /// 批量修改课题组用户
       /// </summary>
       /// <param name="paras"></param>
       /// <returns></returns>
       public ResponseInfo EditTeamInfo(string paras)
       {
           ResponseInfo response = new ResponseInfo();

           string[] paraAtt = paras.Split(',');
           string teamid = paraAtt[0];
 
           Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
           //先删除去掉的数据
           DataTable dtUserTeam = data.QueryTeamUserByTeam(teamid);//当前数据库数据
           for (int j = 0; j < dtUserTeam.Rows.Count; j++)
           {
               int con = 0;//标记位,1-有一样id
               for (int k = 1; k < paraAtt.Length; k++)
               {
                   if (paraAtt[k].ToString() == dtUserTeam.Rows[j]["USER_ID"].ToString())
                   {
                       con = 1;
                       break;
                   }
               }
               if (con == 0)
               { 
                   //删除该条数据
                   data.deleteTeamUserByUserId(dtUserTeam.Rows[j]["USER_ID"].ToString());

               }
           }
            //插入新增加的数据
            for (int i = 1; i < paraAtt.Length; i++)
            {
                if (isExitTeamUser(Convert.ToDecimal(teamid), paraAtt[i].ToString()))
                    continue;
                else
                {
                    response.Data = data.EditTeamInfo(teamid, paraAtt[i].ToString());
                }
            }
               
           return response;
       }
       /// <summary>
       /// 批量修改课题组数据管理员用户
       /// </summary>
       /// <param name="paras"></param>
       /// <returns></returns>
       public ResponseInfo EditTeamDataAdminInfo(string paras)
       {
           ResponseInfo response = new ResponseInfo();

           string[] paraAtt = paras.Split(',');
           string teamid = paraAtt[0];

           Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
           response.Data = data.EditTeamDataAdminInfo(teamid, paraAtt);
           return response;
       }

       /// <summary>
       /// 插入用户到课题组用户表
       /// </summary>
       /// <param name="teamid"></param>
       /// <param name="users"></param>
       /// <returns></returns>
       public bool AddTeamUser(decimal teamid, string userid)
        {
            bool result = false;//返回值
           //先判断是否存在记录
            bool config = isExitTeamUser(teamid, userid);
            if (config == true)
                return true;
            else {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                return data.AddTeamUser(teamid, userid);
            }
            return result;
        }
       /// <summary>
       /// 判断是否存在TeamUser
       /// </summary>
       /// <param name="teamid"></param>
       /// <param name="users"></param>
       /// <returns></returns>
       public bool isExitTeamUser(decimal teamid, string userid)
       {
           Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
           return data.isExitTeamUser(teamid, userid);
       }


        /// <summary>
        /// 用户信息编辑 
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ResponseInfo EditUserInfo(Base_UserInfoCond cond)
        {
            if (string.IsNullOrEmpty(cond.USER_ID))
            {
                cond.USER_ID = Guid.NewGuid().ToString();
            }
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = data.EditUserInfo(cond);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[EditUserInfo:]" + ex.ToString());
            }
            return response;
        }

        /// <summary>
        /// 验证密码
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ResponseInfo verifyPassword(Base_UserInfo cond)
        {

            ResponseInfo response = null;
            try
            {
                cond.USER_ID = LoginUserBiz.LoginUserID();
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = data.verifyPassword(cond);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[EditStaffUserInfo:]" + ex.ToString());
            }
            return response;
        }
        /// <summary>
        /// 用户修改密码
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ResponseInfo EditStaffUserInfo(Base_UserInfo cond)
        {

            ResponseInfo response = null;
            try
            {
                cond.USER_ID = LoginUserBiz.LoginUserID();
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = data.EditStaffUserInfo(cond);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[EditStaffUserInfo:]" + ex.ToString());
            }
            return response;
        }

       
        /// <summary>
        /// 取用户权限
        /// </summary>
        /// <param name="User_ID"></param>
        /// <returns></returns>
        public ResponseInfo QueryUserRightInfo(string User_ID)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (List<Base_UserRightInfo>)data.GetUserRight(User_ID);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[QueryUserInfoList:]" + ex.ToString());
            }
            return response;

        }

        /// <summary>
        /// 角色权限
        /// </summary>
        /// <param name="ROLES_ID"></param>
        /// <returns></returns>
        public ResponseInfo QueryRoleRightsByID(string ROLES_ID)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (List<Base_RoleRightInfo>)data.QueryRoleRightsByID(ROLES_ID);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[QueryRoleRightsByID:]" + ex.ToString());
            }
            return response;

        }

        /// <summary>
        /// 编辑角色权限
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ResponseInfo EditRoleRights(Base_RoleRightsCond cond)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = data.EditRoleRights(cond);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[EditRoleRights:]" + ex.ToString());
            }
            return response;

        }
        /// <summary>
        /// 编辑角色文档操作权限
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ResponseInfo EditRoleOpraRights(Base_FileRoleRightCond cond)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = data.EditRoleOpraRights(cond);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[EditRoleOpraRights:]" + ex.ToString());
            }
            return response;

        }
        /// <summary>
        /// 获取当前角色文档操作权限
        /// </summary>
        /// <returns></returns>
        public ResponseInfo GetRoleOpraRight(string roleId)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (Base_RoleOpraRightsCond)data.GetRoleOpraRight(roleId);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[GetRoleOpraRight:]" + ex.ToString());
            }
            return response;
        }

        public ResponseInfo QueryRoleTreeRights()
        {
            ResponseInfo response = null;
            try
            {
                string userId = LoginUserBiz.LoginUserID();
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (List<FileRightsInfo>)data.QueryRoleTreeRights(userId);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[QueryRoleTreeRights:]" + ex.ToString());
            }
            return response;
        }

        /// <summary>
        /// 角色目标树
        /// </summary>
        /// <param name="ROLES_ID"></param>
        /// <returns></returns>
        public ResponseInfo QueryRoleTreeByID(string ROLES_ID)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (List<Base_RoleRightInfo>)data.QueryRoleTreeByID(ROLES_ID);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[QueryRoleTreeByID:]" + ex.ToString());
            }
            return response;

        }

        /// <summary>
        /// 编辑角色目标树权限
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ResponseInfo EditRoleTree(TargetFileRightCond cond)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = data.EditRoleTree(cond);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[EditRoleRights:]" + ex.ToString());
            }
            return response;

        }

        /// <summary>
        /// 取用户组
        /// </summary>
        /// <param name="User_ID"></param>
        /// <returns></returns>
        public ResponseInfo QueryUserGroup(string User_ID)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (List<Base_UserInfoUserGroupInfo>)data.GetUserGroup(User_ID);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[QueryGetUserGroup:]" + ex.ToString());
            }
            return response;

        }

        /// <summary>
        /// 取用户角色
        /// </summary>
        /// <param name="User_ID"></param>
        /// <returns></returns>
        public ResponseInfo QueryUserRole(string User_ID)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (List<Base_UserRoleInfo>)data.GetUserRole(User_ID);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[QueryUserRole:]" + ex.ToString());
            }
            return response;

        }

        /// <summary>
        /// 取当前用户角色
        /// </summary>
        /// <returns></returns>
        public ResponseInfo QueryCurrentUserRole()
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (List<Base_RoleInfo>)data.QueryCurrentUserRole(LoginUserBiz.LoginUserID());
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[QueryCurrentUserRole:]" + ex.ToString());
            }
            return response;

        }

        /// <summary>
        /// 取员工所在部门
        /// </summary>
        /// <param name="User_ID"></param>
        /// <returns></returns>
        public ResponseInfo GetStaffOrganize(string User_ID)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (List<Base_StaffOrganizeInfo>)data.GetStaffOrganize(User_ID);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[GetStaffOrganize:]" + ex.ToString());
            }
            return response;

        }


        /// <summary>
        /// 系统登陆日志
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ResponseInfo AddSysLoginLog(Base_SysLoginLogInfo cond)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                data.AddSysLoginLog(cond);
                response.Success("success");
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[AddSysLoginLog:]" + ex.ToString());
            }
            return response;

        }

        /// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ResponseInfo ResetPassword(Base_ResetPassword cond)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                cond.password=cond.password.ToUpper();
                response.Data=data.ResetPassword(cond);
                response.Success("success");
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[ResetPassword:]" + ex.ToString());
            }
            return response;

        }


        /// <summary>
        /// 系统日志列表
        /// </summary>
        /// <param name="cond"></param>
        /// <param name="page"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        public ResponseInfo QuerySysLoginLogList(Base_SysLoginLogInfo cond, PageInfo page, OrderInfo order)
        {
            ResponseInfo response = null;
            try
            {

                response = new ResponseInfo();
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response.Data = (List<Base_SysLoginLogInfo>)data.QuerySysLoginLog(cond, page, order);
                response.Page = page;
            }
            catch (Exception ex)
            {
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[QuerySysLoginLogList:]" + ex.ToString());
            }

            return response;
        }


        /// <summary>
        /// 查询员工登陆日志
        /// </summary>
        /// <param name="cond"></param>
        /// <param name="page"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        public ResponseInfo QueryLoginLogInfoList(Base_UserInfo cond, PageInfo page, OrderInfo order)
        {
            ResponseInfo response = null;
            try
            {

                response = new ResponseInfo();
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response.Data = (List<Base_SysLoginLogInfo>)data.GetLoginLogInfo(cond, page, order);
                response.Page = page;
            }
            catch (Exception ex)
            {
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[QueryLoginLogInfoList:]" + ex.ToString());
            }

            return response;
        }


        /// <summary>
        /// 取用户组列表
        /// </summary>
        /// <returns></returns>
        public ResponseInfo GetUserGroupList()
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (List<Base_UserGroupInfo>)data.GetUserGroupList();

            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[GetUserGroupList:]" + ex.ToString());
            }
            return response;

        }


        /// <summary>
        /// 初始用户组
        /// </summary>
        /// <returns></returns>
        public ResponseInfo InitUserGroupParentId()
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (List<Base_UserGroupInfo>)data.InitUserGroupParentId();
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[InitUserGroupParentId:]" + ex.ToString());
            }
            return response;
        }


        /// <summary>
        /// 用户组
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ResponseInfo Load_UserInfoUserGroupList(Base_UserGroupInfo cond)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (List<Base_UserInfo>)data.Load_UserInfoUserGroupList(cond);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[Load_UserInfoUserGroupList:]" + ex.ToString());
            }
            return response;

        }

        public ResponseInfo UserInfoUpdateSpaceStatus(Base_UserInfoSpaceStatusCond cond)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (bool)data.UserInfoUpdateSpaceStatus(cond);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[UserInfoUpdateSpaceStatus:]" + ex.ToString());
            }
            return response;

        }

        /// <summary>
        /// 课题组
        /// </summary>
        /// <returns></returns>
        public ResponseInfo GetSpaceListByUserId() {
            ResponseInfo response = null;
            try
            {
                string userId=LoginUserBiz.LoginUserID();
                List<Base_UserSpaceInfo> list = new Tb_Team_UserBiz().GetSpaceListByUserId(userId);
                response = new ResponseInfo();
                response.Data =list;
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[GetSpaceListByUserId:]" + ex.ToString());
            }
            return response;
        }


        public ResponseInfo GetUserMaxFileRole() {
            ResponseInfo response = null;
            try
            {
                string userId=LoginUserBiz.LoginUserID();
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (Base_FileRoleRightCond)data.GetUserMaxFileRole(userId); ;
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[GetUserMaxFileRole:]" + ex.ToString());
            }
            return response;
        }

        /// <summary>
        /// 新增反馈
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ResponseInfo FeedbackAdd(Base_FeedBackInfo cond)
        {
            ResponseInfo response = null;
            try
            {
                cond.USER_ID = LoginUserBiz.LoginUserAccount();
                cond.USER_NAME = LoginUserBiz.LoginUserName();
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (bool)data.FeedbackAdd(cond);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[FeedbackAdd:]" + ex.ToString());
            }
            return response;

        }

        /// <summary>
        /// 删除反馈
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ResponseInfo DelFeedBack(string Feedback_id)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (bool)data.DelFeedBack(Feedback_id);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[DelFeedBack:]" + ex.ToString());
            }
            return response;

        }
        /// <summary>
        /// 反馈状态
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ResponseInfo SaveFeadbackAuthority(Base_TableAuthorityCond cond)
        {
            ResponseInfo response = null;
            try
            {
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response = new ResponseInfo();
                response.Data = (bool)data.SaveFeadbackAuthority(cond);
            }
            catch (Exception ex)
            {
                //生成返回对象（带错误信息）
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[EditDictItem:]" + ex.ToString());
            }
            return response;

        }
        

        public ResponseInfo QueryFeedbackInfoList(Base_FeedbackCond cond, PageInfo page, OrderInfo order)
        {
            ResponseInfo response = null;
            try
            {

                response = new ResponseInfo();
                Base_RM_UserInfoData data = new Base_RM_UserInfoData(Config.TadongDbProvider);
                response.Data = (List<Base_FeedBackInfo>)data.QueryFeedbackInfoList(cond, page, order);
                response.Page = page;
            }
            catch (Exception ex)
            {
                response = new ResponseInfo("error！");
                LogHelper.WriteLog(LogType.Error, "[QueryFeedbackInfoList:]" + ex.ToString());
            }

            return response;
        }


    }

}
